home *** CD-ROM | disk | FTP | other *** search
/ Chip 2005 August (Alt) / CHIP 2005-08.1.iso / program / guvenlik / syslinux-3.07.exe / sample / c32entry.S < prev    next >
Encoding:
Text File  |  2005-01-03  |  2.2 KB  |  68 lines

  1. #ident "$Id: c32entry.S,v 1.5 2005/01/03 08:23:16 hpa Exp $"
  2. # -----------------------------------------------------------------------
  3. #   
  4. #   Copyright 2003 H. Peter Anvin - All Rights Reserved
  5. #
  6. #   Permission is hereby granted, free of charge, to any person
  7. #   obtaining a copy of this software and associated documentation
  8. #   files (the "Software"), to deal in the Software without
  9. #   restriction, including without limitation the rights to use,
  10. #   copy, modify, merge, publish, distribute, sublicense, and/or
  11. #   sell copies of the Software, and to permit persons to whom
  12. #   the Software is furnished to do so, subject to the following
  13. #   conditions:
  14. #   
  15. #   The above copyright notice and this permission notice shall
  16. #   be included in all copies or substantial portions of the Software.
  17. #   
  18. #   THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  19. #   EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
  20. #   OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  21. #   NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
  22. #   HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
  23. #   WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  24. #   FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  25. #   OTHER DEALINGS IN THE SOFTWARE.
  26. #
  27. # -----------------------------------------------------------------------
  28.  
  29. # COM32 start up code - must be linked first in the binary
  30.  
  31.     
  32.         .section ".text","ax"
  33.         .globl _start
  34. _start:
  35.         # This first instruction acts as COM32 magic number
  36.         movl $0x21cd4cff,%eax
  37.  
  38.         # Upwards string operations
  39.         cld
  40.  
  41.         # Zero the .bss segment
  42.         xorl %eax,%eax
  43.         movl $__bss_start,%edi        # Symbol provided by linker
  44.         movl $_end+3,%ecx        # Symbol provided by linker
  45.         subl %edi,%ecx
  46.         shrl $2,%ecx
  47.         rep ; stosl
  48.  
  49.         # Copy COM32 invocation parameters
  50.         leal 4(%esp),%esi        # Argument list
  51.         movl $__com32,%edi
  52.         movl $6,%ecx
  53.         movl %esp,-4(%edi)        # Save the initial stack ptr
  54.         cmpl (%esi),%ecx
  55.         jbe 1f
  56.         movl (%esi),%ecx
  57. 1:        rep ; movsl
  58.  
  59.         # Run program; we call this __start rather than main since we
  60.         # did not parse the command line or anything like that.
  61.         jmp __start
  62.  
  63.         .section ".bss","aw"
  64.         .globl __entry_esp
  65. __entry_esp:    .space 4
  66.         .globl __com32
  67. __com32:    .space 4*6
  68.